package com.aaa.service;

import com.aaa.dao.CourseDao;
import com.aaa.dao.impl.CourseDaoImpl;
import com.aaa.entity.CourseEntity;
import com.aaa.entity.Message;
import com.aaa.entity.Pager;
import com.aaa.util.PageUtil;

import java.util.List;
import java.util.Map;

public class CourseServiceImpl implements CourseService {
    private CourseDao dao=new CourseDaoImpl();
    @Override
    public Pager queryByPages(int pageNo, Map condation) {
        int pageSize= PageUtil.PAGE_SIZE;
        return dao.queryByPages(pageNo,pageSize,condation);
    }

    @Override
    public Message course_Update(CourseEntity course,int teacher) {
        Message message=new Message();
        int result=-1;
        if (course.getCourseId()==0){
            result=dao.course_add(course,teacher);
            if (result>=1){
                message=new Message(200,"录入成功");
            }else {
                message=new Message(300,"录入失败");
            }
        }else {
            result=dao.course_update(course,teacher);
            if (result>=1){
                message=new Message(200,"修改成功");
            }else {
                message=new Message(300,"修改失败");
            }
        }


        return message;
    }

    @Override
    public Map queryOne(int course_id) {
        return dao.queryOne(course_id);
    }

    @Override
    public int delete(int course_id) {
        return dao.course_delete(course_id);
    }

    @Override
    public List queryType() {
        return dao.queryType();
    }

    @Override
    public int updateState(int state, int course_id) {
        return dao.updateState(state,course_id);
    }

    @Override
    public List queryTeacher() {
        return dao.queryTeacher();
    }


}
